//
// Copyright (c) 2009-2011, chunquedong
//
// This file is part of ChunMap project
// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE(Version >=3)
//
// History:
//   2011-05-03  Jed Young  Creation
//

using chunmapModel

**
** Layer
**
@Js
@Serializable
abstract class Layer
{
  Bool isVisible := true
  Str name := ""

  Renderer? renderer

  abstract Envelope envelope()

  Void render(RenderEnv r)
  {
    if (!isVisible) return
    if (renderer == null) return
    if (r.view.scale < renderer.minScale) return
    if (r.view.scale > renderer.maxScale) return

    renderer.startRender(r)
    renderer.times.times |i|
    {
      renderLayer(i, r)
    }
    renderer.endRender(r)
  }

  protected abstract Void renderLayer(Int step, RenderEnv r)

  override Str toStr() { name }
}